<?php

//小站统计控制器: 访客与粉丝
class Site_statis extends Controller {

	var $userid;
	var $site;
	var $owner;
	
	function Site_statis()
	{
		parent::Controller();	
		$this->load->model("accounts_model", "am");
		$this->load->model("site_model", "sm");
		$this->load->model("sitestatis_model", "ssm");
		$this->load->model("message_model");
		//检测登陆状态
		$this->userid = $this->am->is_logined();
	}
	
	//JS调用：小站总数
	function sites()
	{
		//JS输出
		$sites = $this->sm->count_site();
		j($sites);
	}
	
	//JS调用：新邮件
	function message($userid)
	{
		//JS输出
		$messages = $this->message_model->new_messages($userid);
		j($messages);
	}
	
	//JS调用：新通知
	function notice($userid)
	{
		//JS输出
		$notices = $this->message_model->new_notices($userid);
		j($notices);
	}
	
	//JS调用：关注数量
	function funs($siteid)
	{
		//JS输出
		$funs = $this->ssm->get_sitefuns($siteid);
		j($funs);
	}
	
	//JS调用：我关注的数量
	function user_funs($userid)
	{
		//JS输出
		$funs = $this->ssm->get_userfuns($userid);
		j($funs);
	}
	
	//JS调用：今日访客数量
	function visit_today($siteid)
	{
		//JS输出
		//j(1);
		$visits = $this->ssm->get_visits($siteid);
		j($visits);
	}
	
	//JS调用：记录小站访客
	function visit_record($siteid)
	{	
		//检测小站: 小站存在|非站长|游客不记录
		$site = $this->sm->get_site($siteid);
		if(!$this->userid || !$site || $site["userid"] == $this->userid) {
			j('');
		}
		//记录
		$result = $this->ssm->visit_record($siteid, $this->userid);
//		j($result);
	}
	
}

/* End of file */